<%@ Page Language="C#" %>
<%@ Import namespace="IFXplus.Northwind"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            CustomerManager.CreateCustomer(
                txtCustomerID.Text,
                txtCompanyName.Text,
                txtContactName.Text,
                txtContactTitle.Text,
                txtAddress.Text,
                txtCity.Text,
                txtRegion.Text,
                txtPostalCode.Text,
                txtCountry.Text,
                txtPhone.Text,
                txtFax.Text);
            Response.Redirect("customerview.aspx?id=" + txtCustomerID.Text);
        }
        catch (Exception ex)
        {
            lblMessage.Text = "ERRORE: " + ex.Message;
            lblMessage.Visible = true;
            phDetails.Visible = false;
        }
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Customer Create</title>
</head>
<body>
	<form id="frmMain" runat="server">
	<div>
		<asp:Label ID="lblMessage" runat="server" Text="" Visible="false"></asp:Label>
		<asp:PlaceHolder ID="phDetails" runat="server">
			CustomerID = <asp:TextBox ID="txtCustomerID" runat="server" Text=""></asp:TextBox><br />
			CompanyName = <asp:TextBox ID="txtCompanyName" runat="server" Text=""></asp:TextBox><br />
			ContactName = <asp:TextBox ID="txtContactName" runat="server" Text=""></asp:TextBox><br />
			ContactTitle = <asp:TextBox ID="txtContactTitle" runat="server" Text=""></asp:TextBox><br />
			Address = <asp:TextBox ID="txtAddress" runat="server" Text=""></asp:TextBox><br />
			City = <asp:TextBox ID="txtCity" runat="server" Text=""></asp:TextBox><br />
			Region = <asp:TextBox ID="txtRegion" runat="server" Text=""></asp:TextBox><br />
			PostalCode = <asp:TextBox ID="txtPostalCode" runat="server" Text=""></asp:TextBox><br />
			Country = <asp:TextBox ID="txtCountry" runat="server" Text=""></asp:TextBox><br />
			Phone = <asp:TextBox ID="txtPhone" runat="server" Text=""></asp:TextBox><br />
			Fax = <asp:TextBox ID="txtFax" runat="server" Text=""></asp:TextBox><br />
		</asp:PlaceHolder>
		<hr />
		<asp:LinkButton ID="btnSave" runat="server" Text="Salva" OnClick="btnSave_Click" /> | <a href="default.aspx">Torna alla lista</a>
    </div>
    </form>
</body>
</html>
